home *** CD-ROM | disk | FTP | other *** search
- import java.io.BufferedInputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.net.Socket;
-
- class FriendsServer$RecThread extends Thread {
- // $FF: synthetic field
- private final FriendsServer this$FriendsServer;
- Socket socket;
- // $FF: renamed from: in java.io.DataInputStream
- DataInputStream field_0;
- DataOutputStream out;
- String[] arg;
- String nick;
- FriendsServer parent;
- boolean is_nick;
-
- FriendsServer$RecThread(FriendsServer var1, Socket var2, int var3, FriendsServer var4) {
- this.this$FriendsServer = var1;
- this.this$FriendsServer = var1;
- this.nick = "";
- this.socket = var2;
- this.parent = var4;
- this.arg = new String[4];
-
- for(int var5 = 0; var5 < 4; ++var5) {
- this.arg[var5] = "";
- }
-
- }
-
- public synchronized void send(String var1) {
- if (this.this$FriendsServer.debug) {
- System.out.println("sending: " + var1);
- }
-
- if (var1 != null) {
- try {
- this.out.writeBytes(var1);
- } catch (Exception var2) {
- if (this.this$FriendsServer.debug) {
- System.out.println("absence de la socket " + Integer.toString(this.this$FriendsServer.giveId(this.nick)));
- }
-
- this.parent.stop(this.this$FriendsServer.giveId(this.nick), 1);
- }
- }
- }
-
- public char readByte() {
- char var1 = ' ';
-
- try {
- byte var2 = this.field_0.readByte();
- var1 = (char)(var2 < 0 ? 256 + var2 : var2);
- } catch (Exception var3) {
- if (this.this$FriendsServer.debug) {
- System.out.println("fermeture de la socket " + Integer.toString(this.this$FriendsServer.giveId(this.nick)));
- }
-
- this.parent.stop(this.this$FriendsServer.giveId(this.nick), 1);
- }
-
- return var1;
- }
-
- public void read() {
- int var1 = 0;
- int var2 = 0;
- char[] var3 = new char[1024];
- char var4 = this.readByte();
- if (this.this$FriendsServer.debug) {
- System.out.print("receiving: ");
- }
-
- for(; var4 != '\n'; var4 = this.readByte()) {
- if (var4 == ' ' && var1 < 3) {
- this.arg[var1] = new String(var3, 0, var2);
- ++var1;
- var2 = 0;
- } else if (var2 < 1024) {
- var3[var2++] = var4;
- } else {
- this.parent.stop(this.this$FriendsServer.giveId(this.nick), 1);
- }
- }
-
- this.arg[var1] = new String(var3, 0, var2 >= 1024 ? 1024 : var2);
- if (var1 != 3) {
- this.arg[3] = "";
- }
-
- if (this.this$FriendsServer.debug) {
- for(int var5 = 0; var5 < 4; ++var5) {
- System.out.print(this.arg[var5] + " ");
- }
-
- System.out.println("fin receiving");
- }
-
- }
-
- public void run() {
- this.is_nick = false;
- if (this.this$FriendsServer.debug) {
- System.out.println("thread " + Integer.toString(this.this$FriendsServer.giveId(this.nick)) + " demarre");
- }
-
- try {
- this.field_0 = new DataInputStream(new BufferedInputStream(this.socket.getInputStream()));
- this.out = new DataOutputStream(this.socket.getOutputStream());
- } catch (Exception var4) {
- System.out.println(var4);
- }
-
- if (this.this$FriendsServer.debug) {
- System.out.println("entrees sorties crees");
- }
-
- while(true) {
- this.read();
- if (this.arg[0].equals("NICK")) {
- if (!this.is_nick) {
- if (this.parent.isNick(this.arg[1])) {
- this.send(this.nick + " 901\n");
- } else {
- this.nick = this.arg[1];
- this.is_nick = true;
- this.send(this.nick + " 001\n");
- this.send(this.nick + " 002 dea " + this.parent.giveNicks() + "\n");
- this.parent.sendAll(this.this$FriendsServer.giveId(this.nick), this.nick + " JOIN\n");
- if (this.this$FriendsServer.topic != null) {
- this.send(this.nick + " 003 " + this.this$FriendsServer.topicAuthor + " " + this.this$FriendsServer.topic + "\n");
- }
- }
- } else if (this.parent.isNick(this.arg[1])) {
- this.send(this.nick + " 901\n");
- } else {
- String var8 = this.nick;
- this.nick = this.arg[1].trim();
- this.parent.sendAll(var8 + " NICK " + this.nick + "\n");
- }
- } else if (this.arg[0].equals("QUIT")) {
- try {
- this.field_0.close();
- this.out.close();
- this.socket.close();
- this.parent.stop(this.this$FriendsServer.giveId(this.nick), 0);
- } catch (Exception var3) {
- System.err.println(var3);
- }
- } else if (this.arg[1].equals("MSG")) {
- this.this$FriendsServer.sendAll(this.this$FriendsServer.giveId(this.nick), this.arg[0] + " MSG @ " + this.arg[3] + "\n");
- } else if (this.arg[1].equals("ME")) {
- this.this$FriendsServer.sendAll(this.this$FriendsServer.giveId(this.nick), this.arg[0] + " ME @ " + this.arg[3] + "\n");
- } else if (this.arg[1].equals("TOPIC")) {
- this.this$FriendsServer.topic = this.arg[3];
- this.this$FriendsServer.topicAuthor = this.arg[0];
- this.this$FriendsServer.sendAll(this.arg[0] + " TOPIC @ " + this.arg[3] + "\n");
- } else if (this.arg[1].equals("BEEP")) {
- int var1 = this.this$FriendsServer.giveId(this.arg[2]);
- if (var1 != -1) {
- this.this$FriendsServer.sendOne(var1, this.arg[0] + " BEEP\n");
- } else {
- this.this$FriendsServer.sendOne(this.this$FriendsServer.giveId(this.arg[0]), this.arg[0] + " 902\n");
- }
- } else if (this.arg[1].equals("PRIV")) {
- int var5 = this.this$FriendsServer.giveId(this.arg[2]);
- if (var5 != -1) {
- this.this$FriendsServer.sendOne(var5, this.arg[0] + " PRIV @ " + this.arg[3] + "\n");
- } else {
- this.this$FriendsServer.sendOne(this.this$FriendsServer.giveId(this.arg[0]), this.arg[0] + " 902\n");
- }
- } else if (this.arg[1].startsWith("92")) {
- int var6 = this.this$FriendsServer.giveId(this.arg[2]);
- if (var6 != -1) {
- this.this$FriendsServer.sendOne(var6, this.arg[0] + " " + this.arg[1] + "\n");
- }
- } else if (this.arg[1].equals("WHOIS")) {
- int var7 = this.this$FriendsServer.giveId(this.arg[2]);
- if (var7 == -1) {
- this.this$FriendsServer.sendOne(this.this$FriendsServer.giveId(this.arg[0]), this.arg[0] + " 902\n");
- } else {
- String var2 = this.arg[2] + " whois infos: " + ((FriendsServer$RecThread)this.this$FriendsServer.thread.elementAt(var7)).socket.getInetAddress().getHostName();
- var2 = var2 + " - " + ((FriendsServer$RecThread)this.this$FriendsServer.thread.elementAt(var7)).socket.getInetAddress().getHostAddress();
- this.this$FriendsServer.sendOne(this.this$FriendsServer.giveId(this.arg[0]), this.arg[0] + " WHOIS @ " + var2 + "\n");
- }
- }
- }
- }
- }
-